class Auth{}
Auth.prototype.aLocation=function(){//安卓的判断
	let system = uni.getSystemInfoSync();// 获取系统信息
	if (system.platform === 'android') { // 判断平台
		var context = plus.android.importClass("android.content.Context");
		var locationManager = plus.android.importClass("android.location.LocationManager");
		var main = plus.android.runtimeMainActivity();
		var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
		if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
		  return false;
		}else{
			return true;
		}
	}
}
Auth.prototype.noLocation=function(){//获取不到定位的后续操作
	uni.showModal({
		title: '提示',
		content: '请打开定位服务功能',
		showCancel:false, // 不显示取消按钮
	})
}

Auth.prototype.iosLocation=function(){//ios的判断(不确定是否正确)
	var cllocationManger = plus.ios.importClass("CLLocationManager");    
	var enable = cllocationManger.locationServicesEnabled();    
	var status = cllocationManger.authorizationStatus();    
	console.log("enable:" + enable);    
	console.log("status:" + status);    
	if (enable && status != 2) {    
		return true;
	} else {   
		return false;
	}
}
Auth.prototype.authLocation=async function(){
	//#ifdef APP-PLUS
	let res;
	let system = uni.getSystemInfoSync();// 获取系统信息
	if (system.platform === 'android') { // 判断平台
		res=await this.aLocation()
		return res;
	}else if(system.platform === 'ios'){
		res=await this.iosLocation();
		return res;
	}
	//#endif
	
	//#ifdef MP-WEIXIN
	return true//微信小程序不能判断因为它的api没有效果
	//#endif
	
}
let auth=new Auth();
export {auth}